package com.gem.eolane.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gem.eolane.entity.Admin;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface AdminMapper extends BaseMapper<Admin> {

    //查询总记录数
    @Select("select count(*) from admin")
    int totalCount();

    //分页查询管理员
    @Select("select * from admin limit #{value},5")
    List<Admin> findAdminList(int currentPage);

    //逻辑删除
    @Update("update admin set del_ident = #{delIdent} where id = #{id}")
    void banAdmin(Integer id,Integer delIdent);

    //根据adminNumber查询admin是否存在
    @Select("select * from admin where admin_number = #{adminNumber}")
    Admin isAdmin(String adminNumber);

    //添加管理员
    @Insert("insert into admin (admin_number,password,name) values(#{adminNumber},#{password},#{name})")
    void insertAdmin(String adminNumber,String password,String name);


    //根据管理员名称查询对象
    Admin queryAdmin(String adminNumber);
}
